<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/9
 * Time: 18:32
 */
class Circle{

    private  $r;
    private  $radus;
    public function  getArea()
    {
        return 3.14*$this->r*$this->r;

    }
    public function __set($name, $value)
    {
     if ($name=='r'&&$value<0){
         $this->radus=0;
     }
     else
     {
         $this->$name=$value;
     }
        // TODO: Implement __set() method.
    }
  public function __get($name)
  {
      if ($name=="r")
      {
          return $this->radus;

      }
      else
      {
          return $this->$name;
      }
      // TODO: Implement __get() method.
      return $this->$name;
  }
}
$c=new Circle();
$c->r=3;
$c->r=5;
echo $c->radus;

print  $c->getArea();
print '</br>';

$c->r=-3;
echo isset($c)?'存在':'不存在';
echo isset($d)?'存在':'不存在';
print $c->getArea();